#include<iostream>
using namespace std;
int deleteAllX(int arr[],int n,int x){
	int i=0,j=0;
	while(true){
		while(j<n&&arr[j]==x) j++;
		if(j>=n) break;
		arr[i]=arr[j];
		i++,j++; 
	}
	return i;
} 
void Print(int arr[],int n){
	for(int i=0;i<n;i++) cout<<arr[i]<<" ";
}
int main(){
	int arr[]={1,2,3,5,2,2,2};
	int n = deleteAllX(arr,7,2);
	Print(arr,n);
	return 0;
}
